import  java.util.Arrays;

/*
//替换数组里面所有的值
//fill(int[] a,int value)
public class Main{
    public static void main(String[] args){

        int[] arr = new int[5];
        Arrays.fill(arr,8);
        for(int i = 0; i < arr.length; i++){
            System.out.println(arr[i]);
        }

        int[][] array = new int[][]{{1,2,3,4,5},{2,3,4,5,6},{3,4,5,6,7}};
        Arrays.fill(array[0],0,5,1);
        for(int j = 0; j < array.length; j++){
            for(int k = 0; k < array[j].length; k++){
                System.out.print(array[j][k]+" ");
            }
            System.out.println();
        }
        System.out.println();
        Arrays.fill(array[0],3,4,8);
        for(int i = 0; i < array[0].length; i++){
            System.out.print(array[0][i]+" ");
        }
    }
}
 */

/*
//排序
public class Main{
    public static void main(String[] args){
        int[] arr = new int[]{6,5,9,7,3,2,0,1,8};
        Arrays.sort(arr);
        for(int i = 0; i < arr.length; i++){
            System.out.print(arr[i]+" ");
        }
    }
}
 */

/*
//复制数组 copyOf
public class Main{
    public static void main(String[] args){
        int[] arr1 = new int[]{1,2,3};
        int[] arr2 = Arrays.copyOf(arr1,5);
        for(int i = 0; i < arr2.length; i++){
            System.out.print(arr2[i]+" ");
        }
    }
}
 */

/*
//复制数组里面的指定范围的，到新的数组
//相当于截取
public class Main{
    public static void main(String[] args){
        int[] arr3 = new int[]{13,24,65,43,55};
        int[] arr4 = Arrays.copyOfRange(arr3,2,5);
        for(int i = 0; i < arr4.length; i++){
            System.out.print(arr4[i]+" ");
        }
    }
}
 */

/*
//查询数组
//binarySearch(Object[] a, Object key)
public class Main{
    public static void main(String[] args){
        int[] arr3 = new int[]{13,24,65,43,55};
        //使用查询函数时需要先排序
        Arrays.sort(arr3);
        for(int i = 0; i < arr3.length; i++){
            System.out.print(arr3[i]+" ");
        }
        System.out.println();
        System.out.print("值在数组中的位置是第"+(Arrays.binarySearch(arr3,55)+1)+"位");
    }
}

 */

//指定范围内查询数组
//binarySearch(Object[] a, int fromIndex, int toIndex ,Object key)
public class Main{
    public static void main(String[] args){
        char[] arr3 = new char[]{'a','b','c','d','5'};
        //使用查询函数时需要先排序
        Arrays.sort(arr3);
        for(int i = 0; i < arr3.length; i++){
            System.out.print(arr3[i]+" ");
        }
        System.out.println();
        System.out.print("值在数组中的位置是第"+(Arrays.binarySearch(arr3, 0,2,'5')+1)+"位");
    }
}